%{--
This file is part of dbdjasperreport.

Copyright (C) 2008 Kue Vang aka Kou
Licensed under the Eclipse Public License, Version 1.0; 
you may not use this file except in compliance with the License. 
You may obtain a copy of the License at http://www.eclipse.org/legal/epl-v10.html 
Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
See the License for the specific language governing permissions and limitations 
under the License.
--}%

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="layout" content="main" />
		<resource:dateChooser/>
        <title>Edit Report</title>
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${createLinkTo(dir:'')}">Home</a></span>
            <span class="menuButton"><g:link class="list" action="list">Report List</g:link></span>
            <span class="menuButton"><g:link class="create" action="create">New Report</g:link></span>
        </div>
        <div class="body">
            <h1>Edit Report</h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <g:hasErrors bean="${report}">
            <div class="errors">
                <g:renderErrors bean="${report}" as="list" />
            </div>
            </g:hasErrors>
            <g:form method="post" >
                <input type="hidden" name="id" value="${report?.id}" />
                <div class="dialog">
                    <table>
                        <tbody>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="reportSystem">System:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:report,field:'reportSystem','errors')}">
                                    <g:select optionKey="id" from="${ReportSystem.list()}" name="reportSystem.id" value="${report?.reportSystem?.id}" ></g:select>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="reportName">Report Name:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:report,field:'reportName','errors')}">
                                    <input class="orderByText" type="text" maxlength="100" id="reportName" name="reportName" value="${fieldValue(bean:report,field:'reportName')}"/>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="reportTitle">Report Title:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:report,field:'reportTitle','errors')}">
                                    <input class="orderByText" type="text" maxlength="200" id="reportTitle" name="reportTitle" value="${fieldValue(bean:report,field:'reportTitle')}"/>
                                </td>
                            </tr> 
                        	
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="showReport">Show Report:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:report,field:'showReport','errors')}">
                                    <g:select id="showReport" name="showReport" from="${report.constraints.showReport.inList.collect{it.encodeAsHTML()}}" value="${fieldValue(bean:report,field:'showReport')}" ></g:select>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="orderByClauseOverride">Order By Clause Override:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:report,field:'orderByClauseOverride','errors')}">
                                    <input type="text" id="orderByClauseOverride" 
									       name="orderByClauseOverride" class="orderByText" 
										   value="${fieldValue(bean:report,field:'orderByClauseOverride')}"/>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="designer">Designer:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:report,field:'designer','errors')}">
                                    <input type="text" id="designer" name="designer" value="${fieldValue(bean:report,field:'designer')}"/>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="userResponsible">User Responsible:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:report,field:'userResponsible','errors')}">
                                    <input type="text" id="userResponsible" name="userResponsible" value="${fieldValue(bean:report,field:'userResponsible')}"/>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="comments">Comments:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:report,field:'comments','errors')}">
                                    <textarea rows="5" cols="40" name="comments">${report?.comments?.encodeAsHTML()}</textarea>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="reportEnded">Report Ended:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:report,field:'reportEnded','errors')}">
                                    <g:select id="reportEnded" name="reportEnded" from="${report.constraints.reportEnded.inList.collect{it.encodeAsHTML()}}" value="${fieldValue(bean:report,field:'reportEnded')}" ></g:select>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="reportParameters">Report Parameters:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:report,field:'reportParameters','errors')}">
                                    
<ul>
<g:each var="r" in="${report?.reportParameters?}">
    <li><g:link controller="reportParameter" action="show" id="${r.id}">${r}</g:link></li>
</g:each>
</ul>
<g:link controller="reportParameter" params="["report.id":report?.id]" action="create"> <p class="childLink">Add Parameter</p></g:link>

                                </td>
                            </tr> 
                        
                        </tbody>
                    </table>
                </div>
                <div class="buttons">
                    <span class="button"><g:actionSubmit class="save" value="Update" /></span>
                    <span class="button"><g:actionSubmit class="delete" onclick="return confirm('Are you sure?');" value="Delete" /></span>
                </div>
            </g:form>
        </div>
    </body>
</html>
